﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.BandedGrid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;

namespace bvc
{
    public static class GridUtil
    {
        public static int RebuiltStt(GridView gridView)
        {
            return RebuiltStt(gridView, "STT0");
        }

        public static int RebuiltStt(GridView gridView, string FieldName)
        {
            gridView.CheckLoaded();

            int length = gridView.RowCount;
            int rowHandle = 0;
            int stt = 0;
            for (int i = 0; i < length; i++)
            {
                rowHandle = gridView.GetVisibleRowHandle(i);
                if (rowHandle >= 0)
                    gridView.SetRowCellValue(rowHandle, FieldName, ++stt);
            }

            return stt;
        }

        public static int RebuiltStt(BandedGridView gridView)
        {
            return RebuiltStt(gridView, "STT0");
        }

        public static int RebuiltStt(BandedGridView gridView, string FieldName)
        {
            gridView.CheckLoaded();

            int length = gridView.RowCount;
            int rowHandle = 0;
            int stt = 0;
            for (int i = 0; i < length; i++)
            {
                rowHandle = gridView.GetVisibleRowHandle(i);
                if (rowHandle >= 0)
                    gridView.SetRowCellValue(rowHandle, FieldName, ++stt);
            }
            return stt;
        }
    }
}
